package com.qianyu.core.config;



import com.qianyu.core.interceptor.LoginInterceptor;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

/**
 * @author wangzhic
 * @data 2020/8/4 13:37
 * springmvc补充配置
 **/
@Configuration
public class WebMvcConfig implements WebMvcConfigurer {
    /*** 功能描述: 向容器中添加拦截器
     * @return
     * 开发时间 2019/11/29 0029 上午 11:04
     */
    @Bean
    public LoginInterceptor loginInterceptor() {
        return new LoginInterceptor();
    }

    /*** 功能描述: 添加拦截规则
     * @param registry
     * @return
     * 开发时间 2019/11/29 0029 上午 11:04
     */
    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        registry.addInterceptor(loginInterceptor())
                .addPathPatterns("/**")
                .excludePathPatterns("/api/comm/*")
                .excludePathPatterns("/api/open/*")
                .excludePathPatterns("/front/user/getUsers")
                .excludePathPatterns("/front/user/register")
                .excludePathPatterns("/front/orderPay/getPayWay")
                .excludePathPatterns("/front/orderPay/getAccount")
                //放宽对系统登录登出以及静态文件的拦截
                .excludePathPatterns("/swagger-resources/**", "/webjars/**", "/v2/**", "/swagger-ui.html/**","/doc.html");

    }
}
